/**
 * Tests methods inside the Ship class
 */
package javamonsters.tests;

import static org.junit.Assert.assertTrue;

import java.util.Map;

import javamonsters.model.Ship;
import javamonsters.model.TradeGood;


import org.junit.Test;

/**
 * ShipTest class for testing removeCargo method
 * @author Evan
 * @version 1.0
 */
public class ShipTest {
	
	/**
	 * Tests removing when there is 1 of the good in the cargo
	 */
	
	@Test // $codepro.audit.disable disallowTestAnnotation
	public void testRemoveCargo() {
		
		final Ship ship = new Ship(Ship.ShipType.FLEA);
		final Map<TradeGood, Integer> cargoContents = ship.getCargoContents();
		
		ship.addCargo(TradeGood.WATER, 1);
		assertTrue("cargo content size is equal to 1", cargoContents.size() == 1);
		assertTrue("statement is true", cargoContents
				.get(TradeGood.WATER) == 1);
		
		ship.removeCargo(TradeGood.WATER, 1);
		assertTrue("cargo content size is equal to 1", cargoContents.size() == 1);
		assertTrue("statement is true", cargoContents
				.get(TradeGood.WATER) == 0);
		
	}
	
	/**
	 * Tests removing when there is nothing in the cargo
	 */
	
	@Test // $codepro.audit.disable disallowTestAnnotation
	public void testRemoveCargoWithZero() {
		
		final Ship ship = new Ship(Ship.ShipType.FLEA);
		final Map<TradeGood, Integer> cargoContents = ship.getCargoContents();
		
		ship.removeCargo(TradeGood.WATER, 1);
		assertTrue("cargo content size is 0", cargoContents.size() == 0);
		assertTrue("statement is true", cargoContents.get(TradeGood.WATER) == null);
		
	}
	
	/** 
	 * toString method for ShipTest class
	 * @return a String representation of ship test
	 */
	public String toString() {
		return "ship test";
	}

}
